/**
 * 
 */
package py.edu.ucom.cadira.game.event.war;

import org.jdom.Document;
import org.jdom.Element;

import py.edu.ucom.cadira.game.war.WarUser;

/**
 * @author largonet
 * 
 */
public class UserUnregistredEvent extends WarGameEvent {
    private WarUser user;

    public UserUnregistredEvent(WarUser user) {
        this.user = user;
    }

    public UserUnregistredEvent() {
        
    }
	@Override
	public void fromXML(Document xml) {
		Element root = xml.getRootElement();
		Element userUnregisteredNode = root.getChild("UserUnregistredEvent");
		Element userNode = userUnregisteredNode.getChild("usuario");
		user.fromXml(userNode);
	}

	@Override
	public void toXML(Element root) {
		Element userUnregisteredNode = new Element("UserUnregistredEvent");
		Element userNode = user.toXml();
		userUnregisteredNode.addContent(userNode);
		
		root.addContent(userUnregisteredNode);
	}
	public WarUser getUser() {
		return user;
	}

	public void setUser(WarUser user) {
		this.user = user;
	}
	@Override
	public boolean equals(Object obj) {
		if (!(obj instanceof UserUnregistredEvent)) {
			return false;
		}
		UserUnregistredEvent otherObj = (UserUnregistredEvent) obj;
		if (otherObj.getUser().equals(getUser())) {
			return true;
		}
		return false;
	}
}
